﻿using Architecture.API.Application.TraceabilityCommand.PictureCommand;
using MediatR;
using Traceability.Domain;
using Traceability.Domain.Service.PictureService;

namespace Architecture.API.Application.TraceabilityCommandHandler.PictureCommandHandler
{
    /// <summary>
    /// 图片信息反向填充命令处理器
    /// </summary>
    public class PictureReverseFillingCommandHandler : IRequestHandler<PictureReverseFillingCommand, Pictures>
    {
        /// <summary>
        /// 图片服务
        /// </summary>
        protected readonly IPictureService pictureService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="pictureService">图片服务</param>
        public PictureReverseFillingCommandHandler(IPictureService pictureService)
        {
            this.pictureService = pictureService;
        }

        public async Task<Pictures> Handle(PictureReverseFillingCommand request, CancellationToken cancellationToken)
        {
            return await pictureService.GetPictureModel(request.PictureId);
        }
    }
}
